package cc.yugu.yhdw.common.protocol.msg03;

import cc.yugu.yhdw.common.protocol.MsgCode;
import cc.yugu.yhdw.common.protocol.msg05.Msg051000012;
import cc.yugu.yhdw.common.tool.netty.TypeOperator;
import io.netty.buffer.ByteBuf;

import java.util.ArrayList;
import java.util.List;

public class Msg031000011 extends Msg031 {

    public List<Msg051000012.Customer> createList = new ArrayList<Msg051000012.Customer>();
    public List<Msg051000012.Customer> updateList = new ArrayList<Msg051000012.Customer>();
    public List<Msg051000012.Customer> deleteList = new ArrayList<Msg051000012.Customer>();

    @Override
    public int getMsgCode() {
        return MsgCode.MSG_031000011.getCode();
    }


    @Override
    public void writeData(ByteBuf buffer) {
        buffer.writeInt(createList.size());
        for (Msg051000012.Customer e : createList) {
            e.write(buffer);
        }
        buffer.writeInt(updateList.size());
        for (Msg051000012.Customer e : updateList) {
            e.write(buffer);
        }
        buffer.writeInt(deleteList.size());
        for (Msg051000012.Customer e : deleteList) {
            e.write(buffer);
        }
    }

    @Override
    public void readData(ByteBuf buffer) {
        int size1 = buffer.readInt();
        for (int i = 0; i < size1; i++) {
            Msg051000012.Customer customer = new Msg051000012.Customer();
            customer.read(buffer);
            createList.add(customer);
        }
        int size2 = buffer.readInt();
        for (int i = 0; i < size2; i++) {
            Msg051000012.Customer customer = new Msg051000012.Customer();
            customer.read(buffer);
            updateList.add(customer);
        }
        int size3 = buffer.readInt();
        for (int i = 0; i < size3; i++) {
            Msg051000012.Customer customer = new Msg051000012.Customer();
            customer.read(buffer);
            deleteList.add(customer);
        }
    }
}
